package com.mr.example1.index;

import java.io.IOException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

/*
 * 1.输入数据：
 * 		atguigu,a.txt	3
 * 		atguigu,b.txt	3
 *
 * 2.输出数据：
 * 		atguigu,a.txt	3	b.txt	3
 */

public class Example1Reducer2 extends Reducer<Text, Text, Text, Text>{


	@Override
	protected void reduce(Text key, Iterable<Text> values, Reducer<Text, Text, Text, Text>.Context context)
			throws IOException, InterruptedException {

		StringBuffer sb = new StringBuffer();

		for (Text value : values) {

			// 拼接字符串
			sb.append(value.toString() + " ");

		}

		context.write(key, new Text(sb.toString()));

	}

}
